package routers

import (
	"GoTime/controller"

	"github.com/gin-contrib/cors"
	"github.com/gin-gonic/gin"
)

func NewRoute() *gin.Engine {
	//r := gin.Default()
	gin.SetMode(gin.ReleaseMode)
	//gin.DefaultWriter = io.Discard
	r := gin.New()
	config := cors.DefaultConfig()
	config.AllowAllOrigins = true
	config.AllowHeaders = append(config.AllowHeaders, "Authorization")
	r.Use(cors.New(config))
	r.HEAD("/", controller.IndexHead)
	r.POST("/school/login", controller.SchoolLogin) // 用户登录
	menu := r.Group("/menu")
	{
		menu.GET("/get/list", controller.GetMenuList) // 获取菜单
		menu.POST("/add", controller.AddMenu)         // 添加菜单
		menu.POST("/edit", controller.MenuEdit)       // 修改菜单
		//menu.POST("/delete", controller.MenuDelete)   // 删除菜单 备注：暂时不用 使用修改接口is_hidden=1来隐藏菜单
	}
	//school := r.Group("/school").Use(middleware.VerifyToken())
	school := r.Group("/school")
	{
		school.GET("/get/business_scope", controller.GetSchoolBusinessScope) // 获取驾校培训车型
		school.GET("/get/detail", controller.GetSchoolDetail)                // 获取学校详情
		school.POST("/add", controller.AddSchool)                            // 添加学校
		school.POST("/edit", controller.EditSchool)                          // 修改学校
		school.POST("/record", controller.RecordSchool)                      // 备案驾校信息
		school.GET("/get/school/info", controller.GetSchoolInfo)             // 查询驾培机构信息接口 - 新增接口
		school.POST("/licnumchange", controller.LicNumChange)                // 经营许可证变更
	}
	coach := r.Group("/coach")
	{
		coach.GET("/get/list", controller.GetCoachList) // 获取教练列表
		coach.POST("/add", controller.AddCoach)         // 添加教练
		coach.POST("/edit", controller.EditCoach)       // 修改教练
		coach.GET("/delete", controller.DeleteCoach)    // 删除教练
	}
	student := r.Group("/student")
	{
		student.GET("/get/list", controller.GetStudentList) // 获取学生列表
		student.POST("/add", controller.AddStudent)         // 添加学员
		student.POST("/edit", controller.EditStudent)       // 修改学员
		//student.GET("/delete", controller.DeleteStudent)    // 删除学员
		student.GET("/query/info", controller.StudentInfoQuery) // 查询学员信息
		//student.GET("/get/record", controller.GetStudentRecord)         // 查询学员学时
		student.GET("/transfer/apply", controller.StudentTransferApply) // 学员跨培训机构备案
		student.POST("/binding/coach", controller.BindingCoach)         // 绑定教练
		student.POST("/unbinding/coach", controller.UnBindingCoach)     // 绑定教练
		//student.POST("/get/pact", controller.GetStudentPact)            // 获取学员合同
		//student.POST("/add/pact", controller.AddDStudentPact)           //学员保存合同
		student.POST("/pact/content", controller.GetPactContent) // 学员列表获取合同内容
	}
	record := r.Group("/record")
	{
		record.GET("/get/list", controller.GetRecordList)                  // 获取记录列表
		record.GET("/get/detail", controller.GetRecordDetail)              // 获取记录详情
		record.GET("/student/subject", controller.GetStudentSubjectRecord) // 分科目展示学员学时记录
		record.GET("/get/stage/list", controller.GetStageList)             // 阶段学时上报列表
		record.GET("/get/reported/list", controller.GetReportedList)       // 阶段学时审核管理列表
		record.POST("/stage/training", controller.StageTraining)           // 上报生成PDF
	}
	car := r.Group("/car")
	{
		car.GET("/get/list", controller.GetCarList) // 获取车辆列表
		car.POST("/add", controller.AddCar)         // 添加车辆
		car.POST("/edit", controller.EditCar)       // 修改车辆
		car.GET("/delete", controller.DeleteCar)    // 删除车辆
	}
	terminal := r.Group("/terminal")
	{
		terminal.GET("/get/list", controller.GetTerminalList) // 获取终端列表
		terminal.POST("/add", controller.AddTerminal)         // 添加终端
		terminal.GET("/record", controller.RecordTerminal)    // 备案终端信息
		terminal.POST("/edit", controller.EditTerminal)       // 修改终端
		terminal.GET("/delete", controller.DeleteTerminal)    // 删除终端
		terminal.POST("/binding", controller.BindingCar)      // 绑定车辆
		terminal.POST("/unbinding", controller.UnBindingCar)  // 解绑车辆
	}
	field := r.Group("/field")
	{
		field.GET("/get/list", controller.GetFieldList)              // 获取场地列表
		field.POST("/add", controller.AddField)                      // 添加场地
		field.POST("/edit", controller.EditField)                    // 修改场地
		field.GET("/delete", controller.DeleteField)                 // 删除场地
		field.POST("/set/closurePoint", controller.SetClosurePoint)  // 保存围栏坐标点信息
		field.GET("/get/closurePoint", controller.GetClosurePoint)   // 获取围栏坐标点信息
		field.POST("/record", controller.FieldRecord)                // 备案场地信息
		field.GET("/get/lastFieldCode", controller.GetLastFieldCode) // 获取场地最新编号
		field.GET("/get/review", controller.GetRegionReview)         // 查询围栏审核结果
	}
	security := r.Group("/security")
	{
		security.GET("/get/list", controller.GetSecurityList) // 获取安全员列表
		security.POST("/add", controller.AddSecurity)         // 添加安全员
		security.POST("/edit", controller.EditSecurity)       // 修改安全员
		security.GET("/delete", controller.DeleteSecurity)    // 删除安全员
	}
	examiner := r.Group("/examiner")
	{
		examiner.GET("/get/list", controller.GetExaminerList) // 获取考试员列表
		examiner.POST("/add", controller.AddExaminer)         // 添加考试员
		examiner.POST("/edit", controller.EditExaminer)       // 修改考试员
		examiner.GET("/delete", controller.DeleteExaminer)    // 删除考试员

	}
	feedback := r.Group("/feedback")
	{
		feedback.GET("/get/list", controller.GetFeedbackList) // 获取反馈列表
	}
	// 收费标准
	class := r.Group("/class")
	{
		class.GET("/get/list", controller.GetClassList) // 获取班级列表
		class.POST("/add", controller.AddClass)         // 添加班级
		class.POST("/edit", controller.EditClass)       // 修改班级
		class.GET("/delete", controller.DeleteClass)    // 删除班级
	}
	device := r.Group("/device") // 计时终端接口
	{
		device.GET("/auth/coach", controller.AuthCoach) // 获取设备列表
	}
	upload := r.Group("/upload") // 文件资料上传接口
	{
		upload.POST("/image", controller.UploadImage)        // 上传图片
		upload.POST("/images", controller.UploadImageBase64) // 上传图片
	}
	return r
}
